#pragma once
#include <vector>
#include "dataTypes.h"
#include "GFuns.h"
#include "MapDrawer.h"
using namespace std;

class MapDrawer;

class RainDrop
{
	public:
		RainDrop(){};

		RainDrop(int aLife, Point aPosition, float aSpeed, float aDirection)
		{
			life = aLife;
			time = 1;

			speed.x = aSpeed*sin(aDirection);
			speed.y = aSpeed*cos(aDirection);

			position.x = aPosition.x;
			position.y = aPosition.y;

			width = randInterval(1,2);
		}

		int life;
		int time;
		float width;
		Point position;
		Point speed;
};

class Weather
{
	public:
		Weather(EWeatherEffect aEffect);
		~Weather();

		vector<RainDrop>* GetDrops() {return &drops;};
		EWeatherEffect GetEffect() {return actualEffect;};
		void SetMapDrawer(MapDrawer* aDrawer) {drawer = aDrawer;};
		bool IsLightning()
		{
			if(isLightning)
			{
				isLightning = false;
				return true;
			}
			else return false;
		}

		void Tick();

	private:
		vector<RainDrop> drops;
		EWeatherEffect actualEffect;
		bool isLightning;

		MapDrawer* drawer;

		unsigned int maxDrops;
		float direction;
		float minSpeed, maxSpeed;
		float minLife, maxLife;

		void AddDrop(bool aStarting = false);
};
